package com.xc.h05.service.lishenao.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xc.h05.entity.Fm;
import com.xc.h05.mapper.FmMapper;
import com.xc.h05.service.lishenao.FmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class FmServiceImpl implements FmService {
    @Autowired
    private FmMapper fmMapper;
    @Override
    public PageInfo<Fm> findAllByFm(Integer pageNum, Integer pageSize, Fm fm) {
        PageHelper.startPage(pageNum,pageSize);
        List<Fm> fms = fmMapper.findAllByFm(fm);
        PageInfo<Fm> pageInfo = new PageInfo<>(fms);
        return pageInfo;
    }

    @Override
    public int add(Fm fm) {
        return fmMapper.insert(fm);
    }

    @Override
    public int update(Fm fm) {
        return fmMapper.updateByPrimaryKey(fm);
    }

    @Override
    public int delete(Long id) {
        return fmMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Fm findById(Long id) {
        return fmMapper.selectByPrimaryKey(id);
    }
}
